﻿Namespace EIBData.DPT
    Public NotInheritable Class EIBDataDPT_20_006
        Inherits EIBDataDPT_20_Base

        Public Enum EIBDataDPT_20_006_Values
            NoFault = 0
            System_Function_of_common_interest = 1
            HVAC_general_FB = 10
            HVAC_Hot_Water_Heating = 11
            HVAC_Direct_Electrical_Heating = 12
            HVAC_Terminal_Units = 13
            HVAC_VAC = 14
            Lighting = 20
            Security = 30
            Load_Management = 40
            Shutters_Blinds = 50
        End Enum

        Protected _value As EIBDataDPT_20_006_Values = Nothing


        Sub New(data As Byte())
            MyBase.New(data)

            _value = _valueBase
        End Sub

        Sub New(value As EIBDataDPT_20_006_Values)
            MyBase.New(value)

            _value = value
        End Sub


        Public Overrides Function ToInfoList() As List(Of EIB.InfoBase)
            Dim list As New List(Of EIB.InfoBase)

            list.Add(New EIB.Info("Type", DPT_Name))
            If _value > 50 Then
                list.Add(New EIB.Info("Value", String.Format("{0} (0x{1:X})", "Reserved", _value)))
            ElseIf _value > 40 AndAlso _value < 50 Then
                list.Add(New EIB.Info("Value", String.Format("{0} (0x{1:X})", "Reserved (Load Management)", _value)))
            ElseIf _value > 30 AndAlso _value < 40 Then
                list.Add(New EIB.Info("Value", String.Format("{0} (0x{1:X})", "Reserved (Security)", _value)))
            ElseIf _value > 20 AndAlso _value < 30 Then
                list.Add(New EIB.Info("Value", String.Format("{0} (0x{1:X})", "Reserved (Lighting)", _value)))
            ElseIf _value > 14 AndAlso _value < 20 Then
                list.Add(New EIB.Info("Value", String.Format("{0} (0x{1:X})", "Reserved (HVAC)", _value)))
            ElseIf _value > 1 AndAlso _value < 10 Then
                list.Add(New EIB.Info("Value", String.Format("{0} (0x{1:X})", "Reserved", _value)))
            Else
                list.Add(New EIB.Info("Value", String.Format("{0} (0x{0:X})", _value)))
            End If

            Return list
        End Function

        Public Shared Shadows ReadOnly Property DPT_Name As String
            Get
                Return "DPT_ApplicationArea"
            End Get
        End Property

        Public Shared Shadows ReadOnly Property DPT_Number As String
            Get
                Return "20.006"
            End Get
        End Property

        Public Overrides Function ToString() As String
            If _value > 50 Then
                Return "Reserved"
            ElseIf _value > 40 AndAlso _value < 50 Then
                Return "Reserved (Load Management)"
            ElseIf _value > 30 AndAlso _value < 40 Then
                Return "Reserved (Security)"
            ElseIf _value > 20 AndAlso _value < 30 Then
                Return "Reserved (Lighting)"
            ElseIf _value > 14 AndAlso _value < 20 Then
                Return "Reserved (HVAC)"
            ElseIf _value > 1 AndAlso _value < 10 Then
                Return "Reserved"
            Else
                Return _value
            End If
        End Function

        Public Overloads ReadOnly Property Value As EIBDataDPT_20_006_Values
            Get
                Return _value
            End Get
        End Property
    End Class
End Namespace